package com.implemetsystem.prestacontas.geral.manager;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;

import com.implementsystem.prestacontas.orgaos.entity.Orgao;
import com.implementsystem.prestacontas.orgaos.session.OrgaoSession;

@Named(value="orgaoManager")
@ConversationScoped
public class OrgaoManager extends GenericManager implements Serializable{

	private static final long serialVersionUID = 8254896639785206960L;


	//@EJB
	//private OrgaoClient orgaoClient;
	@EJB
	private OrgaoSession session;
	
	
	private List<Orgao> orgaos = new ArrayList<Orgao>();
	private Orgao orgao = new Orgao();
	private String ano;
	private Boolean mostrar = false;
	
	
	public String prepararOrgaos() throws Exception{
		orgaos = new ArrayList<Orgao>();
		
		orgaos = session.findAllOrderByDescricao();
		return "orgaoTeste";
		
	}
	
	
	/*
	public String teste(){
		orgaos = new ArrayList<Orgao>();
		
		try {
			
			orgaos = session.findAllOrderByDescricao();
			
			if(orgaos == null || orgaos.isEmpty()){
				orgaos = orgaoClient.listaOrgaos().getOrgaos();
				
				if(orgao != null && !orgaos.isEmpty()){
					for (Orgao orgao : orgaos) {
						session.save(orgao);
					}
				}
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		} 
		
		return "orgaoTeste";
	}
	
	*/
	
	public List<Orgao> getOrgaos() {
		
		return orgaos;
		
	}
	
	public void setOrgaos(List<Orgao> orgaos) {
		this.orgaos = orgaos;
	}
	
	public String selecionarAno(){
		//orgaos = session.findAllOrderByDescricao();
		mostrar = true;
		ano = "";
		return null;
	}
	
	public void verResultado(){
		
	}
	
	public Orgao getOrgao() {
		return orgao;
	}
	public void setOrgao(Orgao orgao) {
		this.orgao = orgao;
	}

	public Boolean getMostrar() {
		return mostrar;
	}
	public void setMostrar(Boolean mostrar) {
		this.mostrar = mostrar;
	}

	public String getAno() {
		return ano;
	}
	public void setAno(String ano) {
		this.ano = ano;
	}

	
}
